package cn.al2.fast;

import sun.applet.Main;

import java.util.*;

/**
 * 第一课：new 与 static
 * <p>
 * 思考空间暂用 和  速度
 * <p>
 * 为了避免单线程阻塞 影响观察效果
 */
public class Lesson_1 {
    public static void main(String[] args) {

        System.out.println(new ArrayList<>());
        System.out.println(Collections.emptyList());


        new Thread(() -> {
            Map<String, Object> m1 = new HashMap<>();
            long l = System.currentTimeMillis();
            for (int i = 0; i < 1000000; i++) {
                m1.put(i + "", new ArrayList<>());
            }
            long endTimeNew = System.currentTimeMillis() - l;

            System.out.println("endTimeNew==" + endTimeNew + "线程ID==" + Thread.currentThread().getId());
        }).start();


        new Thread(() -> {
            Map<String, Object> m2 = new HashMap<>();
            long l2 = System.currentTimeMillis();
            for (int i = 0; i < 1000000; i++) {
                m2.put(i + "", Collections.emptyList());
            }
            long endTimeStatic = System.currentTimeMillis() - l2;

            System.out.println("endTimeStatic==" + endTimeStatic + "线程ID==" + Thread.currentThread().getId());
        }).start();


    }
}
